#!/bin/bash

# Need to start by creating and running a docker container using the commented out code immediately below. Once in the docker container, run this script within the container to train the models. Point the docker container to the overarching folder, in my case "Replication Attempt 1"

# docker run --gpus=all --shm-size 8G --net=host -p 8888:8888 --name Replication1 -v 'path/to/main/folder':/opt -e JUPYTER_ENABLE_LAB=yes -it public.aml-repo.cms.waikato.ac.nz:443/pytorch/detectron2:0.6

# Because of the label-studio annotation process, the annotated documents are already in their respective folders. It is important to note here that the meetings identified in step 1 are not the same here due to the lack of a reproducible random selection process. To carry out the process yourself, replace the annotated files in the the Annotated Training set with your own annotated data.

# Uncomment these installation commands to add the required packages to the docker container. Then, run this bash script from the command terminal WITHIN the docker container using the command "bash 'Step 3/Step 3.sh'"

#pip install jupyterlab 
#pip install notebook
#pip3 install wheel setuptools pip --upgrade
#python3 -m pip install -U pypdfium2
#pip install layoutparser torchvision && pip install "git+https://github.com/facebookresearch/detectron2.git@v0.5#egg=detectron2"
#apt update
#apt -y install poppler-utils
#pip3 install PyPDF2
#pip install label-studio
#pip install -U scikit-learn
#pip install funcy
#pip install openpyxl
#pip install "layoutparser[ocr]"
#apt install tesseract-ocr
#pip install Pillow==9.5.0 
#pip install ipykernel

# Convert ipynb to py and runs python script
chmod +x 'Step 3/Model Training.ipynb'

jupyter nbconvert --to python 'Step 3/Model Training.ipynb'

python3 'Step 3/Model Training.py'


